<template>
	<view class="like" style="overflow: hidden;">
		
			<block v-if="listData.length>0">
				<view class="t23">
					<view v-for="(item,idx) in listData" :key="idx" @click="goTo('/pages/home/shopDetail?productid='+item.productBaseId+'&store='+JSON.stringify(store))">
						<view><image class="img1" :src="item.imageUrl"></image></view>
						<view class="t24">
							<view>
								{{item.title}}
							</view>
							<view>
								<image class="img2" :src="imgUrl+'9.png'" mode="widthFix"></image>
							</view>
							<view class="t25">
								¥{{item.costPrice}}<text>¥{{item.price}}</text>
							</view>
						</view>	
						
					</view>
				</view>
				<u-loadmore 
						marginBottom="50"
				        :status="status" 
				        :loading-text="loadingText" 
				        :loadmore-text="loadmoreText" 
				        :nomore-text="nomoreText" 
				/>
			</block>
			<block v-else>
				<u-empty marginTop="100" :text="emptyTips" mode="list"></u-empty>
			</block>
	</view>
</template>

<script>
	
	export default{
		components:{
			
		},
		data() {
		 
			return {
				store: "",
				storeArray: [],
				imgUrl:this.imgUrl,
				emptyTips:"您还没有收藏喜欢的商品~",
				status: 'loadmore',
				loadingText: '努力加载中',
				loadmoreText: '轻轻上拉',
				nomoreText: '没有了哦',
				pageindex:1,
				listData:[]
			}
		},
		  computed: {
		      
		    },
		onLoad() {
			this.GetMyCollectList();
			// uni.getStorageSync("storeId")
			this.$a.GetOpenToken().then(()=>{
			
				this.getLocation();
			})
		},
		methods: {
			getLocation() {
				uni.getLocation({
					type: 'wgs84',
					success: (res) => {
						this.$http.GetAllStore({
							code: "L68lO1",
							lng: res.longitude,
							lat: res.latitude,
							distance: 5000
						}).then(res => {
							this.store = res.content[0]
							this.storeArray = res.content
							uni.setStorageSync("store", this.store)
							uni.setStorageSync("storeId", this.store.storeId)
						})
					}
				});
			},
			GetMyCollectList(){
				this.status = "loading"
				// this.$http.GetProductList({
				// 	tagid:2,
				// 	pagesize:10,
				// 	pageindex:this.pageindex,
				// 	storeId:5
				// })
				this.$http.GetMyCollectList({
					pagesize:20,
					pageindex:this.pageindex,
				})
				.then(res => {
					if(res.code==0){
					this.status = "loadmore";
					if(res.content.length>0){
						this.listData = this.listData.concat(res.content);
						if(res.content.length<10){
							this.status = "nomore"
						}
					}else{
						this.status = "nomore"
					}
					}
				})
			},
			
		},
		onReachBottom() {
			this.pageindex ++;
			this.GetMyCollectList()
		}
	}
</script>

<style lang="scss" scoped>
	
	.t23{
		padding: 0 30rpx;margin-top: 30rpx;
		>view{
			width: 330upx;
			height: 504upx;
			background: #FFFFFF;
			box-shadow: 0px 2upx 11upx 0upx rgba(0,0,0,0.1);
			border-radius: 16upx;
			display: inline-block;
			border-radius: 20upx;
			margin-right: 30upx;
			margin-bottom: 20upx;
			.img1{
				width: 100%;
				height: 300upx;
				border-top-left-radius: 20upx;
				border-top-right-radius: 20upx;
			
			}
			.t24{
				padding: 20upx;
				.img2{
					width: 72upx;
					height: 40upx;
					margin: 20upx 0;
				}
				.t25{
					font-size: 28upx;
					font-weight: 500;
					color: #333333;
					text{
						font-size: 24upx;
						font-weight: 400;
						display: inline-block;
						text-decoration:line-through;
						color: #999999;
						margin-left: 24upx;
					}
				}
			}
			
		}
		>view:nth-child(2n){
			margin-right: 0;
		}
	}
	
</style>